#include "GN1621_Parts.h"
#include "../Y36_LCD_horizontal/App_Main.h"

#ifndef UI_H
#define UI_H

#define Oven_Setting_Min_F 180 //F
#define Oven_Setting_Max_F 500 //F
#define Probe_Setting_Min_F 50 //F
#define Probe_Setting_Max_F 225 //F
#define Alarm_Probe_Min 0 //F

#define Oven_Setting_Min_C 82 //C
#define Oven_Setting_Max_C 260 //C
#define Probe_Setting_Min_C 10 //C
#define Probe_Setting_Max_C 107 //C

typedef enum
{
    Unit_F = 2,
    Unit_C = 3,
}Grill_Unit_E;
typedef enum
{
    Alarm_None = 0,
    Alarm_Timer1,
    Alarm_RTD,
    Alarm_ProbeA_Enable,
    Alarm_ProbeA_Action,
    Alarm_ProbeB_Enable,
    Alarm_ProbeB_Action,
}UI_Alarm_E;
typedef enum
{
    UI_OFF = 0,
    UI_ON,

    UI_Shine,
}UI_State_E;
typedef enum
{
    UI_None = 0,
    UI_RTD,
    UI_RTDSettings,
    UI_Timer_Hour,
    UI_Timer_Minute,
    UI_ProbeA,
    UI_ProbeASettings,
    UI_ProbeB,
    UI_ProbeC,
}UI_Number_E;
typedef enum
{
    Shine_Normal = 0, //正常不闪耀
    Shine_OFF, //闪耀-关闭
    Shine_ON, //闪耀-显示
}Shine_E;
typedef enum
{
    Alart_None = 0,
    Alart_Action,
}Alart_Type;
typedef struct
{
    int32_t Actual;
    int32_t Settings;   
    int32_t Settings_Modifiing;   
    uint8_t IsChanged;
    Alart_Type Alart_State;
}UI_Param_Typedef;
typedef struct
{
    uint64_t Actual;
    uint64_t Settings;
}UI_TimeParam_S;


typedef struct 
{
    UI_Param_Typedef RTD;
    UI_Param_Typedef ProbeA;
    UI_Param_Typedef ProbeB;
    UI_Param_Typedef ProbeC;
    UI_TimeParam_S Timer1;
    Shine_E Shine_WIFI;
    Shine_E Shine_AugerErr;
    Shine_E Shine_FanErr;
    Shine_E Shine_IgnitorErr;
    Shine_E Shine_RTD_Setting;
    Shine_E Shine_ProbeA_Actual;
    uint8_t Shine_Pause; //暂停2s
    uint8_t Shine_End; //闪耀停止倒计时

    UI_State_E Grill_state;
	UI_State_E State_TempCtrl;
    UI_Number_E State_Operation;
    UI_State_E ICO_WIFI;
    UI_State_E ICO_Bluetooth;
    UI_State_E ICO_Auger;
    UI_State_E ICO_Fan;
    UI_State_E ICO_Heating;
    UI_State_E ICO_Error;
    UI_State_E ICO_Error_Auger; 
    UI_State_E ICO_Error_Fan; 
    UI_State_E ICO_Error_Ignite; 
    UI_State_E ICO_Cell;
    UI_State_E OTA_Check;
    UI_State_E LCD_State; 

    UI_State_E Is_Reset;

    UI_Alarm_E Alarm_Timer;
    UI_Alarm_E Alarm_RTD;
    UI_Alarm_E Alarm_ProbeA;
    UI_Alarm_E Alarm_ProbeB;
    UI_Alarm_E Alarm_ProbeC;

    Grill_Unit_E Grill_Unit;

    uint16_t PowerUp_Delay; //Tick 10ms
}UI_System_S;
extern UI_System_S UI_System;

void UI_Encoder_KeyLong(void);
void UI_Encoder_Key(void);
void UI_Encoder_R(void);
void UI_Encoder_L(void);
void UI_Clock(void);
void UI_Init(void);
void UI_Main(void);
void UI_TempCtrl_Start(void);
void UI_TempCtrl_Stop(void);
void Setting_Exit();
void Setting_Exit_RTD();

UI_State_E UI_Grill_Normal(void);

uint16_t F_Convert_C(uint16_t F);
void UI_Default_F(void);
void UI_Default_C(void);

#endif
